package iit.projects.etaxi.model.service;

import iit.projects.etaxi.model.dao.MessageDao;
import iit.projects.etaxi.model.entity.Message;

import java.util.List;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Transactional(readOnly=true)
public class MessageServiceImpl implements MessageService {

	private MessageDao messageDao;
	
	@Override
	@Transactional(readOnly=false, propagation=Propagation.REQUIRES_NEW)
	public void deleteMessages(List<Message> messages) {
		messageDao.deleteMessages(messages);
	}

	@Override
	@Transactional(readOnly=false, propagation=Propagation.REQUIRES_NEW)
	public void saveMessages(List<Message> messages) {
		messageDao.saveMessages(messages);

	}

	@Override
	@Transactional(readOnly=false, propagation=Propagation.REQUIRES_NEW)
	public List<Message> updateMessages(List<Message> messages) {
		return messageDao.updateMessages(messages);
	}
	
	@Override
	public List<Message> findAllMessages(){
		return messageDao.findAllMessages();
	}

	public void setMessageDao(MessageDao messageDao) {
		this.messageDao = messageDao;
	}

}
